package com.wwl.cms.utils.designModeTest.prototype;

import lombok.extern.slf4j.Slf4j;

/**
 * @author wwl
 * @version 1.0
 * @date 2021/9/5 21:29
 * @description:
 */
@Slf4j
public class Client {
    public static void main(String[] args) throws CloneNotSupportedException {
        System.out.println("原型模式完成对象的创建。");
        /*Sheep sheep = new Sheep("tom",1,"白色");
        Sheep sheep1 = (Sheep)sheep.clone();//克隆
        Sheep sheep2 = (Sheep)sheep.clone();//克隆
        Sheep sheep3 = (Sheep)sheep.clone();//克隆

       log.info("sheep:{},{}",sheep.toString(),sheep.hashCode());
       log.info("sheep2:{},{}",sheep2.toString(),sheep2.hashCode());
       log.info("sheep3:{},{}",sheep3.toString(),sheep3.hashCode());*/
        //方式一完成深拷贝
        DeepProtoType p = new DeepProtoType("宋江", new DeepCloneableTarget("大牛","小牛"));
        DeepProtoType p2 = (DeepProtoType)p.clone();
        log.info("p，{}，{}，{}",p.name,p.deepCloneableTarget,p.deepCloneableTarget.hashCode());
        log.info("p2，{}，{}，{}",p2.name,p2.deepCloneableTarget,p2.deepCloneableTarget.hashCode());
    }
}
